package com.java.service.Impl;

import com.java.dao.Impl.UserDaoImpl;
import com.java.dao.UserDao;
import com.java.entity.Users;
import com.java.service.UserService;
import com.java.util.MyException;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    UserDao dao=new UserDaoImpl();
    @Override
    public Users login(String uId, String pwd) throws MyException {
        try {
            Users users = dao.selectUserByUnameAndByPwd(uId, pwd);
            return users;
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException("登录查询语句出错");
        }
    }

    @Override
    public void register(Users user) throws MyException {
        try {
            dao.insertUser(user);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException("插入新用户SQL出错");
        }
    }

    @Override
    public void updateUser(Users user) throws MyException {
        try {
            dao.updateUser(user);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException("修改普通用户的SQL出错");
        }
    }
}
